﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;

using System.IO;

using XMK.Tadong.InnerElement;
using XMK.Framework.ElasticSearch;
using XMK.Tadong.Model;
using System.Diagnostics;

namespace XMK.Tadong.DataSyncService
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            

            Console.WriteLine("正在启动扫描服务...");

            Tasker.StartAll();

            while (true)
            {
                string updaterName = Console.ReadLine();
                try
                {
                    Tasker.Start(updaterName);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Message.ToString());
                }
            }
        }

        static void TestESSearch()
        {
            //查询使用接口示例
            //主要要求理解 ElasticSearchQuery 的各个方法代表的含义
            ElasticSearchConnection conn =
                new ElasticSearchConnection("localhost", 9500, "xmkfileindex", ConnectionType.Thrift);
            ElasticSearchDataAccess db = new ElasticSearchDataAccess(conn);
            long recordCount = 0;

            //全文检索：ElasticSearchQuery.Lk("fILE_ABST", "东方财富", "mmseg")
            //日期检索：ElasticSearchQuery.Gt("uPD_TIME", DateTime.Now)
            //年龄检索：ElasticSearchQuery.Eq("BIZ_OBJ", 26)
            var results = db.ExecuteQuery<XMKFileInfo>(ElasticSearchQuery.Lk("fILE_ABST", "开发人员", "mmseg"), "xmkfileinfo", 1, 10, ref recordCount);
            foreach (var item in results)
            {
                Console.WriteLine(item.FILE_NAME);
            }

        }

    }
}
